package com.clock.shop.service.impl;

import com.clock.shop.repository.ActivityRepository;
import com.clock.shop.repository.ServiceRepository;
import com.clock.shop.repository.ShopRepository;
import com.clock.shop.service.IUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserSearchServiceImpl implements IUserSearchService {
        @Autowired
        private ShopRepository shopRepository;
        @Autowired
        private ServiceRepository serviceRepository;
        @Autowired
        private ActivityRepository activityRepository;

        @Override
        public Map<String, List<?>> search(String keyword) {
                Map<String, List<?>> results = new HashMap<>();
                results.put("shops", shopRepository.findByShopNameContaining(keyword));
                results.put("services", serviceRepository.findByServiceNameContaining(keyword));
                results.put("activities", activityRepository.findByActivityNameContaining(keyword));
                return results;
        }
}
